<template>
  <div class="w">
    <div class="header">
      <i class="iconfont icon-fanhui" @click="back"></i>
      <span class="title">勤工俭学</span>
    </div>
    <div class="info">
      <div class="info_header">
        <div class="info_header_title">
          <div class="title_left">
            <span>{{ jobList.jobName }}</span>
          </div>
          <div class="title_right">
            <span>{{ jobList.salary }}元/月</span>
          </div>
        </div>
        <div class="info_header_bottom">
          <span>{{ jobList.shop }}</span>
        </div>
        <div class="info_header_date">
          <span>更新于{{ updateTime }}</span>
        </div>
      </div>
      <div class="info_details">
        <div class="info_details_contacts">
          <div class="contacts_title">联系人</div>
          <div class="contacts_info">
            <span>{{ jobList.people }}</span>
            <span>{{ jobList.jobPhone }}</span>
          </div>
        </div>
        <div class="info_details_ask">
          <div class="ask_title">兼职要求</div>
          <div class="ask_info">
            <span>{{ jobList.askFor }}</span>
          </div>
        </div>
        <div class="info_details_text">
          <div class="text_title">兼职描述</div>
          <div class="text_info">
            <span>{{ jobList.jobText }}</span>
          </div>
        </div>
        <div class="info_details_text">
          <div class="text_title">剩余名额</div>
          <div class="text_info">
            <span>{{ jobList.quota }}</span>
          </div>
        </div>
      </div>
    </div>
    <div class="bottom">
      <div class="button">
        <el-button @click="goSignUp">立即报名</el-button>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      jobId: '',
      jobList: [],
      createTime: '',
      updateTime: '',
    };
  },

  created() {
    this.jobId = this.$route.query.jobId;
    this.getJobDetails();
  },

  methods: {
    goSignUp() {
      if (this.jobList.quota <= 0) {
        return this.$message.error('该职位报名人数已满，请选择其他职位');
      }
      this.$router.push({ path: '/signUp', query: { jobId: this.jobId } });
    },
    back() {
      this.$router.go(-1);
    },
    async getJobDetails() {
      const { data: res } = await this.$http.get('job/getById/' + this.jobId);
      if (res.code == 1) {
        this.jobList = res.data;
        this.jobList.createTime = this.jobList.createTime.split(' ');
        this.createTime = this.jobList.createTime[0];
        this.jobList.updateTime = this.jobList.updateTime.split(' ');
        this.updateTime = this.jobList.updateTime[0];
        return;
      } else {
        return this.$message.error('信息获取失败');
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.w {
  height: 10vh;
  width: 100%;
  .header {
    background-color: #fece4e;
    height: 50px;
    color: #fff;
    text-align: center;
    position: relative;
    .icon-fanhui {
      position: absolute;
      font-size: 25px;
      line-height: 50px;
      left: 10px;
      font-weight: bold;
    }
    .title {
      font-size: 20px;
      line-height: 50px;
      font-weight: bold;
    }
  }
  .info {
    height: 600px;
    overflow: auto;
    padding: 15px;
    margin-top: 15px;
    scrollbar-width: none;
    -ms-overflow-style: none;
    background-color: #fefefe;
    .info_header {
      position: relative;
      height: 110px;
      border-bottom: 1px solid #fcfcfc;
      .info_header_title {
        display: flex;
        position: relative;
        margin-bottom: 15px;
        justify-content: space-between;
        .title_left {
          text-overflow: ellipsis;
          display: -webkit-box;
          font-size: 30px;
          color: #272a2b;
          letter-spacing: 5px;
          width: 265px;
          overflow: hidden;
          -webkit-line-clamp: 1;
          -webkit-box-orient: vertical;
        }
        .title_right {
          font-size: 18px;
          color: #617ae1;
          font-weight: bold;
          position: absolute;
          bottom: 0;
          right: 0;
        }
      }
      .info_header_bottom {
        font-size: 15px;
        letter-spacing: 2px;
        margin-bottom: 5px;
      }
      .info_header_date {
        position: absolute;
        margin-bottom: 10px;
        right: 0;
        color: #adb2b8;
        font-size: 13px;
        letter-spacing: 1px;
      }
    }
    .info_details {
      .info_details_contacts {
        margin-bottom: 20px;
        letter-spacing: 2px;
        border-bottom: 1px solid #f1f1f1;
        .contacts_title {
          margin-top: 15px;
          font-size: 20px;
          color: #212121;
          margin-bottom: 10px;
        }
        .contacts_info {
          display: flex;
          margin-bottom: 15px;
          justify-content: space-between;
        }
      }
      .info_details_ask {
        margin-bottom: 20px;
        letter-spacing: 2px;
        border-bottom: 1px solid #f1f1f1;
        .ask_title {
          margin-top: 15px;
          font-size: 20px;
          color: #212121;
          margin-bottom: 10px;
        }
        .ask_info {
          margin-bottom: 15px;
        }
      }
      .info_details_text {
        margin-bottom: 20px;
        letter-spacing: 2px;
        border-bottom: 1px solid #f1f1f1;
        .text_title {
          margin-top: 15px;
          font-size: 20px;
          color: #212121;
          margin-bottom: 10px;
        }
        .text_info {
          margin-bottom: 15px;
        }
      }
    }
  }
  .bottom {
    height: 150px;
    text-align: center;
    .button {
      line-height: 150px;
      :deep(.el-button) {
        width: 350px;
        background-color: #5e7aee;
        color: #fefefe;
        height: 50px;
        border: none;
        font-size: 15px;
        border-radius: 50px;
      }
    }
  }
}
</style>